package com.nanrui.mutualinductor.utils;


import android.content.Context;

public class SPUtil
{
    private static final String FILE_NAME = "Settings";

    public static int getCheckTurns(Context paramContext)
    {
        return getParam(paramContext, "CHECK_TURNS", 8);
    }

    public static String getLastAddr(Context paramContext)
    {
        return getParam(paramContext, "LAST_ADDR", null);
    }

    public static long getMeterConstant(Context paramContext)
    {
        return getParam(paramContext, "METER_CONSTANT", 3600L);
    }

    public static float getParam(Context paramContext, String paramString, float paramFloat)
    {
        return paramContext.getSharedPreferences("Settings", 0).getFloat(paramString, paramFloat);
    }

    public static int getParam(Context paramContext, String paramString, int paramInt)
    {
        return paramContext.getSharedPreferences("Settings", 0).getInt(paramString, paramInt);
    }

    public static long getParam(Context paramContext, String paramString, long paramLong)
    {
        return paramContext.getSharedPreferences("Settings", 0).getLong(paramString, paramLong);
    }

    public static String getParam(Context paramContext, String paramString1, String paramString2)
    {
        return paramContext.getSharedPreferences("Settings", 0).getString(paramString1, paramString2);
    }

    public static Float getPowerFactor(Context paramContext)
    {
        if (isContain(paramContext, "POWER_FACTOR")) {
            return Float.valueOf(getParam(paramContext, "POWER_FACTOR", 0.0F));
        }
        return null;
    }

    public static boolean isContain(Context paramContext, String paramString)
    {
        return paramContext.getSharedPreferences("Settings", 0).contains(paramString);
    }

    public static void setCheckTurns(Context paramContext, int paramInt)
    {
        setParam(paramContext, "CHECK_TURNS", paramInt);
    }

    public static void setLastAddr(Context paramContext, String paramString)
    {
        setParam(paramContext, "LAST_ADDR", paramString);
    }

    public static void setMeterConstant(Context paramContext, long paramLong)
    {
        setParam(paramContext, "METER_CONSTANT", paramLong);
    }

    public static void setParam(Context paramContext, String paramString, float paramFloat)
    {
        paramContext.getSharedPreferences("Settings", 0).edit().putFloat(paramString, paramFloat).apply();
    }

    public static void setParam(Context paramContext, String paramString, int paramInt)
    {
        paramContext.getSharedPreferences("Settings", 0).edit().putInt(paramString, paramInt).apply();
    }

    public static void setParam(Context paramContext, String paramString, long paramLong)
    {
        paramContext.getSharedPreferences("Settings", 0).edit().putLong(paramString, paramLong).apply();
    }

    public static void setParam(Context paramContext, String paramString1, String paramString2)
    {
        paramContext.getSharedPreferences("Settings", 0).edit().putString(paramString1, paramString2).apply();
    }

    public static void setPowerFactor(Context paramContext, float paramFloat)
    {
        setParam(paramContext, "POWER_FACTOR", paramFloat);
    }
}

